﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.责任链模式
{
    public abstract class AbstractLogger
    {
        public static int INFO = 1;
        public static int DEBUG = 2;
        public static int ERROR = 3;

        protected int level;

        /// <summary>
        /// 责任链中的下一个元素
        /// </summary>
        public AbstractLogger NextLogger { set; get; }

        public void LogMessage(int level,string message)
        {
            if (this.level <= level)
            {
                Write(message);
            }
            if (NextLogger != null)
            {
                NextLogger.LogMessage(level, message);
            }
        }

        abstract protected void Write(string message);
    }
}
